<style lang="scss">
@import "./uv.scss";
</style>
<template>
  <div>
    <div class="common-bg"></div>
    <div style="position: relative; z-index: 2">
      <uv-sticky>
        <div class="pl30 pr30">
          <div style="height: 100rpx; box-sizing: border-box; color: #333">
            <u-my-input v-model="form.keywords" @clear="handleClear" placeholder="请输入手机号/姓名">
              <button @click="searchTap" class="fz30 p1757298517 common-button pl0 pr0 ml0 mr0" style="color: #ffffff; background-color: #e60012">
                搜索
              </button>
            </u-my-input>
          </div>
          <div class="p1757299303" style="box-sizing: border-box">
            <uv-tabs @click="tabTap" :customStyle="{ height: '80rpx' }" :current="current" :scrollable="false" :inactiveStyle="{ color: '#999' }" :activeStyle="{ color: '#333' }" lineColor="#E60012" border :list="list"></uv-tabs>
          </div>
        </div>
      </uv-sticky>
      <div class="p1757296779">
        <scroll-view scroll-anchoring :refresher-triggered="isRefreshing" :refresher-enabled="true" scroll-y scroll-top="0" @refresherrestore="onRefresherRestore" @refresherrefresh="bindrefresherrefresh" @scrolltolower="onReachBottom" style="height: calc(100vh - 44px - 180rpx)">
          <div class="p1757300485" v-for="(item, index) in tableData" :key="index">
            <div class="f">
              <uv-avatar :src="item.avatar" size="80rpx"></uv-avatar>
              <div class="pt10" style="flex: 1">
                <div class="fz30 fac pl20" style="color: #3d3d3d; font-weight: 500">
                  {{ item.nickname }}
                </div>
                <div class="fz30 pt10 pb10 pl20" style="color: #6b7280">
                  ID: {{ item.id }} &nbsp;&nbsp;{{ item.phone_number }}
                </div>
                <div v-for="(i, iI) in item.community_list" :key="index + '-' + iI">
                  <button v-if="i.community_name" class="fz26 p1757318941 common-button    mr0">{{ i.community_name
                        }}</button>
                </div>
              </div>
            </div>
            <div class="p1757299971 pt30 f">
              <div class="p1757299982 fac" style="width: 33%">
                <img style="width: 80rpx;height: 80rpx;" src="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0909/561da202509091006408441.png" alt="">
                <div class="fz30 pt10">
                  消费次数:
                  <div class="fz30" style="display: inline; font-weight: 500">
                    {{ Number(item.number) }}
                  </div>
                </div>
              </div>
              <div class="p1757299982 fac" style="width: 33%">
                <img style="width: 80rpx;height: 80rpx;" src="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0909/499da202509091006574576.png" alt="">
                <div class="fz30 pt10">
                  消费金额:
                  <div class="fz30" style="display: inline; font-weight: 500">
                    {{ Number(item.consumption_amount) }}
                  </div>
                </div>
              </div>
              <div class="p1757299982 fac" style="width: 33%">
                <img style="width: 80rpx;height: 80rpx;" src="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0909/d2648202509091007137153.png" alt="">
                <div class="fz30 pt10">
                  积分:
                  <div class="fz30" style="display: inline; font-weight: 500">
                    {{ Number(item.integral) }}
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="common-empty" v-if="tableData.length === 0 && isOnce">
            <uv-empty mode="data" />
          </div>
          <div v-if="tableData.length" class="p1757319276">
            <uv-load-more fontSize="28rpx" class="" :status="status" />
          </div>
          <div style="width: 100%; height: 20rpx"></div>
        </scroll-view>
      </div>
      <div class="">
        <uv-safe-bottom></uv-safe-bottom>
      </div>
    </div>
  </div>
</template>

<script>
import myInputVue from './components/myInput.vue';
import myLayOutVue from './components/layOut.vue';
import commonMixin from "./mixin/common.js";
import {
  memberList
} from '@/api/community.js';
export default {
  components: {
    'u-my-input': myInputVue,
    'u-my-layOut': myLayOutVue,
  },
  mixins: [commonMixin],
  data() {
    return {
      form: {
        keywords: '',
        page: 1,
        limit: 10,
        sort: 'number',
      },
      communityForm: {},
      current: 0,
      list: [{
        name: '按次数排序',
        sort: 'number',
      },
      {
        name: '按消费金额排序',
        sort: 'consumption_amount',
      },
      ],
    };
  },
  onShow() {
    this.initPage();
  },
  methods: {
    initPage(cb = () => { }) {
      this.isOnce = false;
      if (this.form.page == this.current_page) return;
      uni.showLoading({
        title: '加载中',
        mask: true,
      });
      let form = JSON.parse(JSON.stringify(this.form));
      memberList(form).then((res) => {
        this.isRefreshing = false;
        this.isOnce = true;
        if (res.code === 200) {
          cb();
          uni.hideLoading();
          let data =
            res.result &&
            res.result.data &&
            JSON.parse(JSON.stringify(res.result.data));
          this.total = res.result.total;
          this.current_page = res.result.current_page;
          this.tableData = this.tableData.concat(data);
          if (this.total <= this.tableData.length) this.status = 'nomore';
        }
      }).catch(() => {
        uni.hideLoading();
        this.isRefreshing = false;
        this.isOnce = true;
      });
    },
  },
};
</script>
<style>
page {
  background-color: #f7f8f8;
  color: #333333;
}
</style><style lang="scss" scoped>
@import "./common.scss";
.common-bg {
  top: 0;
  z-index: 1 !important;
}

.bg {
  top: 0;
  left: 0;
  position: fixed;
  width: 100vw;
  z-index: 1;
}

.p1757296779 {
  position: relative;
  z-index: 2;
  padding-left: 30rpx;
  padding-right: 30rpx;
}

.p1757298517 {
  background: #e60012;
  width: 90rpx;
  height: 50rpx;
  border-radius: 24rpx 24rpx 24rpx 24rpx !important;
  margin-top: 10rpx;
  margin-bottom: 10rpx;
  margin-right: 10rpx !important;
}

.p1757299303 {
  background: #ffffff;
  border-radius: 15rpx;
}

.p1757300485 {
  background: #ffffff;
  border-radius: 15rpx;
  box-shadow: 2rpx 2rpx 20rpx 2rpx #eeeeee;
  box-sizing: border-box;
  padding: 30rpx 20rpx;
  margin-bottom: 20rpx;
}

.p1757299971 {
  .p1757299982 {
    font-weight: 500;
    text-align: center;
    flex-direction: column;
    justify-content: flex-start;
  }
}

.p1757318941 {
  font-size: 26rpx !important;
  border-radius: 30rpx !important;
  font-weight: 400 !important;
  color: #c9caca !important;
  border: 2rpx solid #c9caca !important;
  background-color: #fff;
  padding: 5rpx 20rpx !important;
  margin-left: 20rpx !important;
}
</style>
